const { resolve } = require('path')

const mongoose = require(resolve(__dirname, '../db'))

const CategoriesSchema = mongoose.model('categories', new mongoose.Schema({
  categoryName: {
    type: String,
    required: [true, '分类名不可为空!'],
    trim: true
  },
  createTime: {  // 创建时间
    type: Number,  // 时间戳
    min: [1, '时间格式错误'],
    trim: true
  },
  updateTime: {  // 修改时间
    type: Number,  // 时间戳
    trim: true
  },
  categoryNum: {  // 文章数量
    type: Number,
    default: 0,
    trim: true
  },
  isDel: { // 是否删除
    type: Boolean,
    trim: true,
    default: false
  }
}))

module.exports = CategoriesSchema
